/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ai;

/**
 *
 * @author root
 */
public class EqExp extends BoolExp {
    public EqExp(){
    }
    public EqExp(LexExp pLeft, LexExp pRight){
        mLeft = pLeft;
        mRight = pRight;
    }
    public void setLeft(LexExp pExp){
        mLeft = pExp;
    }
    public void setRight(LexExp pExp){
        mRight = pExp;
    }
    public boolean evaluate(){
        if (mLeft instanceof StringExp && mRight instanceof StringExp){
            return ((StringExp)mLeft).getString().equals(((StringExp)mRight).getString());
        }
        else if (mLeft instanceof LabelExp && mRight instanceof LabelExp) {
            return ((LabelExp)mLeft).getName().equals(((LabelExp)mRight).getName());
        }
        else {
            return mLeft.equals(mRight);
        }
    }
    public LexExp substitute(String pLabelName, String pString){
        return new EqExp(mLeft.substitute(pLabelName, pString), mRight.substitute(pLabelName, pString));
    }
    private LexExp mLeft;
    private LexExp mRight;

}
